<?php

// @formatter:off
/**
 * @file Class.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: Class.php 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/extensions/Repositories/Class.php $
 */
define("WC_E_REPOSITORIES_VERSION", "1.0");
define("WC_E_REPOSITORIES_ROOTDIR", __DIR__);
define("WC_E_REPOSITORIES_URI", substr(WC_E_REPOSITORIES_ROOTDIR, strlen($_SERVER["DOCUMENT_ROOT"])));
define("WC_E_REPOSITORIES_ALLOWED", 10001);
define("WC_E_REPOSITORIES_MAINDIR", "/Repository");
define("WC_E_REPOSITORIES_PREDIR", WC_E_REPOSITORIES_MAINDIR."/pre-repo");
define("WC_E_REPOSITORIES_PREDIR_DURATION", 30); // in days
define("WC_E_REPOSITORIES_MAX", 100);
define("WC_E_REPOSITORIES_IMAX", 500);

$extensionBasicInfo = array(
	"name" => "Repositories",
	"description" => "Keep comics into repositories when unsorted",
	"author" => "Alejandro Dario Simi",
	"version" => WC_E_REPOSITORIES_VERSION,
	"url" => array(
		"title" => "wcomix:Extension:Repositories",
		"href" => "http://wiki.daemonraco.com/wiki/Wcomix:Extension:Repositories"
	)
);

$wcCronScripts["CTRepositories"] = array_merge($extensionBasicInfo, array(
	"auto" => true,
	"enabled" => true,
	"class" => "CTRepositories"
	));
$wcCronProfiles[$wcCronProfile][] = "CTRepositories";

$auxDIR = substr(__DIR__, strlen($wcROOTDIR));
$wcDatabase["tables"][] = "{$auxDIR}/db/wc_prerepo.tab.xml";
$wcDatabase["indexes"][] = "{$auxDIR}/db/wc_prerepo.pk.xml";

$wcPermissions["pyramid-perms"]["ORGANIZER"][] = WC_E_REPOSITORIES_ALLOWED;

$wcPaths["mvc"]["pools"]["actions"][] = __DIR__;
$wcPaths["mvc"]["pools"]["skins"]["actions"][] = __DIR__;
//
// Menu @{
function WC_E_REPOSITORIES_MenuBuilder($code) {
	if($code == WC_MENU_CODE_ADMIN) {
		global $wcGroup;
		global $wcMenuItems;

		$wcMenuItems[WC_MENU_CODE_ADMIN]["middle"][] = array(
			"name" => "Repositories",
			"title" => "Repositories Status",
			"ficon" => WC_E_REPOSITORIES_URI."/images/repositories-256px.png",
			"url" => "?action=repositories:status&group={$wcGroup->id()}"
		);
	}
}
$wcMenuBuilders[] = "WC_E_REPOSITORIES_MenuBuilder";
//@}

require_once WC_E_REPOSITORIES_ROOTDIR."/includes/WCERepository.php";
require_once WC_E_REPOSITORIES_ROOTDIR."/includes/WCEComicsRepository.php";
require_once WC_E_REPOSITORIES_ROOTDIR."/includes/WCEImagesRepository.php";
//
// Loading cron.
// Warning: they only load when it is a shell execution.
// @{
if(defined("__SHELL__")) {
	require_once WC_E_REPOSITORIES_ROOTDIR."/includes/CTRepositories.php";
}
